<?php
/*
 *
 *
 */

?>
<?php 
//配置项
    $homeUrl     = $this->getUrl('');//首页路径
    $this_store  = Mage::app()->getStore()->getStoreId();//视图判断
    $skin_url    = $this->getSkinUrl();//当前皮肤路径

    $sf_advantage = ($this_store == '2') ? $homeUrl.'skin/frontend/em0131/em0131_marketdeal/images/landing-page/icod/ru/' : $homeUrl.'skin/frontend/em0131/em0131_marketdeal/images/landing-page/icod/en/';
	$automobilesBener = ($this_store == '2') ? $skin_url.'images/landing-page/automobiles_motorcycles/ru/' : $skin_url.'images/landing-page/automobiles_motorcycles/en/';

    /* 抢拍产品切换时间 */
    date_default_timezone_set("Etc/GMT-3");
    $thisTime = date("Y/m/d H:i:s",time());
?>

<style type="text/css">
	#em-mheader{padding-bottom:0px; margin-bottom: 0px;}
	#em-mheader .em-top-search{padding-bottom:0px;}

	#bannerAsd {display: none !important;}
	.em-header-style31 {margin: 0px;}
	.em-wrapper-main .container-main{margin: 0px;padding: 0px;width: 100%;}
	.em-main-container.em-col1-layout >div.row{margin: 0px;}
	.em-main-container.em-col1-layout >div.row >div.em-col-main{margin: 0px;}
	.em-main-container >div >div{margin: 0px;padding: 0px;}
	
	.em-wrapper-footer .em-footer-style09 .em-footer-info-bottom {margin: 0;padding: 0;border-top: 1px solid #ddd;}
	.em-wrapper-footer .em-area-footer02{display: none;}
</style>

<div class="activity automobiles_motorcycles">
	<div class="activity_header">				
		<div class="sf_advantage">
			<ul>
	            <li><img src="<?php echo $sf_advantage ?>New_6.png" alt=""></li>
	            <li><img src="<?php echo $sf_advantage ?>New_7.png" alt=""></li>
	        </ul>
		</div>
		<div class="activity_banner">
			<div class="advertising">
				<div class="advertising_banner"><img src="<?php echo $this->getSkinUrl() ?>images/landing-page/automobiles_motorcycles/automobiles_motorcycles.jpg" alt=""></div>
				<div class="advertising_coupon">

<!-- coupon -->
<?php 
//配置项
$coupon_url = $this->getBaseUrl()."autocoupon/new/sendEmailCoupon/";
$rule_id    = array('45','46','47');
?>
			<div class="sf_coupon_form">
				<form action="<?php echo $coupon_url ?>" method="post" id="sf_coupon">
					<div class="input-box">
						<input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" name="email" id="sf_coupon_email" title="ign up for Discounts" class="input-text required-entry validate-email">
						<input type="hidden" name="events_code" value="automobiles_motorcycles">
					</div>
					<div class="actions">
						<button type="submit" title="Подписаться" class="button"><span><span>Получить купон</span></span></button>
					</div>
				</form>
				<div id="sf_coupon_box"></div>
			</div>
<script type="text/javascript">
//<![CDATA[
(function($){
		function CheckMail(mail) {
		 	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		 	if (filter.test(mail)) {
		 		return true;
		 	}else {
		 		return false;
			}
		}


        $('.sf_coupon_obj').click(function(){
			$('.sf-coupon').toggle();
		});
		$('.coupon_code span').click(function(){
			$('.sf-coupon').toggle();
		});

		$('#sf_coupon').submit(function(){
			var email       = $("#sf_coupon_email").val();
			var events_code = $("#sf_coupon input[name=events_code]").val();
			var rule_id     = <?php echo json_encode($rule_id); ?>;
			var view_url    =  $("#sf_coupon").attr("action");

			
			var	checemail = CheckMail(email);
			if(checemail){
				if(email && events_code && rule_id ){
					$("#sf_coupon_box").html('<div><img src="<?php echo $homeUrl; ?>skin/frontend/em0131/default/images/opc-ajax-loader.gif"></div>');
					$.post(view_url,{"email":email,events_code:events_code,rule_id:rule_id},function(data){
						if(data == 'success'){
			                $("#sf_coupon_box").css({'background': '#fff','margin-top': '5px','border': '1px solid #fff','border-radius': '5px',"color":"#434343"});
							$("#sf_coupon_box").html('Ура! Ваши купоны были отправлены на ваш email!');					
						}else{
							$("#sf_coupon_box").css({'background': '#fff','margin-top': '5px','border': '1px solid #fff','border-radius': '5px',"color":"#e33e3e"});
							$("#sf_coupon_box").html('Приносим извинения, акция уже закончилась. Заходите на <a href="<?php echo $this->getBaseUrl() ?>" > Rumall.com</a>, тут всегда много интересного.');
						}
					},"json" );
				}				
			}
			return false;
		})
})(jQuery);
//]]>
</script>



				</div>
			</div>
		</div>
	</div>

	<div class="substance">
		<div class="sf_explain">
			<a href="<?php echo $homeUrl ?>automobiles_motorcycles_rule" target="_blank" ><img src="<?php echo $automobilesBener ?>qg.jpg" alt=""></a>
			<!-- <p><?php //echo $this->__("Don't wait to get the best deals as freebies can be finish at") ?></p>
			<p><?php //echo $this->__('anytime') ?></p> 
			<p><?php //echo $this->__('New items every 3 days') ?></p> -->
		</div>
		<div class="activity_auction">
			<div class="category-products">
				<?php
					$documens  = Mage::helper('categorypage/auction')->getEvents('1');
					$auctions  = $documens->getProducts();
					$begintime = $documens->begintime();
					$begintime = date('Y-m-d H:i:s',strtotime('-0 Hour',strtotime($begintime)));
				?>
				<?php if (!empty($auctions)): ?>
				<div id="em-grid-mobile">
					<ul>
						<li class="col-sm-6">
							<div class="sf-auction-product">
								<div class="sf-banenr">
									<a href="https://www.rumall.com/mobiles-telecoms/mobile-phone-accessories/screen-protectors?dir=asc&order=price"><img src="https://www.rumall.com/media/catalog/product/cache/2/thumbnail/300x300/9df78eab33525d08d6e5fb8d27136e95/2/0/20160829122254_29068.jpg" alt=""></a>
									<p><span class="price" style="color:#e33e3e;"><?php echo  Mage::helper('core')->currency('0.1', true, false) ?></span></p>
								</div>
								<div class="text-center">
									<div class="product-name"><a href="https://www.rumall.com/mobiles-telecoms/mobile-phone-accessories/screen-protectors?dir=asc&order=price"><?php echo $this->__('Baixin') ?></a></div>
								</div>
								<div class="sf-flipclock"></div>
								<div class="sf-shop-now">
									<a href="https://www.rumall.com/mobiles-telecoms/mobile-phone-accessories/screen-protectors?dir=asc&order=price"><span><?php echo $this->__('Shop Now'); ?></span></a>
								</div>
							</div>
						</li>
						<?php foreach ($auctions as $_product): ?>
								<?php 
								 	$_productId   = $_product['id'];
									$_productUrl  = $_product['url'];
									$_productName = $_product['name'];
									$_productImg  = $_product['thumbnail'];
									$_productSfPrice = $_product['sf_price'];
									$_productCurrencyFinalPrice = $_product['currency_final_price'];
								?>
								<li class="col-sm-6">
									<div class="sf-auction-product">
										<div class="sf-banenr">
											<a href="<?php echo $_productUrl; ?>"><img src="<?php echo $_productImg; ?>" alt=""></a>
											<p><span class="price" style="color:#e33e3e;">
												<?php 
													if (strtotime($thisTime) > strtotime($begintime)){
														echo $_productCurrencyFinalPrice;
													}else{
														echo $_productSfPrice;
													} 
												?>
											</span></p>
										</div>
										<div class="text-center">
											<div class="product-name"><a href="<?php echo $_productUrl; ?>"><?php echo $_productName ?></a></div>
										</div>
										<div class="sf-flipclock"></div>
										<div class="sf-shop-now">
											<a href="<?php echo $_productUrl; ?>"><span><?php echo $this->__('Shop Now'); ?></span></a>
										</div>
									</div>
								</li>
						<?php endforeach ?>
					</ul>
					<div style="clear: both;"></div>
				</div>
				<?php endif ?>
			</div>
			<script type="text/javascript">
				//<![CDATA[
				(function($){
					/* 抢拍倒计时 */
					var interval = 1000;
					var thisTime = "<?php echo $thisTime ?>";
					var begintime = "<?php echo $begintime ?>"
					var page_starttime = '<div class="countdown_patry"><div><p><?php echo $this->__("Deal Start in:"); ?></p><div class="patry" ><div class="patry_s"><div class="days"><span>0</span><span>0</span></div><div class="text_party">:</div><div class="hours"><span>0</span><span>0</span></div><div class="text_party">:</div><div class="minutes"><span>0</span><span>0</span></div><div class="text_party">:</div><div class="seconds"><span>0</span><span>0</span></div></div><div class="patry_r"><div><?php echo $this->__("days"); ?></div><div class="text_party"></div><div><?php echo $this->__("hours")?></div><div class="text_party"></div><div><?php echo $this->__("minutes"); ?></div><div class="text_party"></div><div><?php echo $this->__("seconds"); ?></div></div></div></div></div>';

					var now = new Date();
					var phpnowtime = new Date(thisTime);
					var starttime = new Date(begintime);
					var nowtime_s = now.getTime() - phpnowtime.getTime();
					if(starttime.getTime() > phpnowtime.getTime() ){
						var seconds  = starttime.getTime();
						$('.sf-flipclock').append(page_starttime);
						window.setInterval(function(){ShowCountDown();}, interval);
					}else{
						$('.sf-flipclock').append(page_starttime);
					}
					
					function ShowCountDown()
					{
						
						var now        = new Date();
						var now_js     = now.getTime() - nowtime_s;
						var leftTime   = seconds - now_js;
						if(leftTime > 0){	
							var leftsecond = parseInt(leftTime/1000);
							var day    = Math.floor(leftsecond/(60*60*24));
							var hour   = Math.floor((leftsecond-day*24*60*60)/3600);
							var minute = Math.floor((leftsecond-day*24*60*60-hour*3600)/60);
							var second = Math.floor(leftsecond-day*24*60*60-hour*3600-minute*60);
							if(day < 10){
								$(".days").html('<span>0</span><span>'+day+'</span>');
							}else {
								$(".days").html(day);
							}
							if(hour < 10){
								$(".hours").html('<span>0</span><span>'+hour+'</span>');
							}else {
								$(".hours").html(hour);
							}
							if(minute < 10){
								$(".minutes").html('<span>0</span><span>'+minute+'</span>');
							}else {
								$(".minutes").html(minute);
							}
							if(second <10 ){
								$(".seconds").html('<span>0</span><span>'+second+'</span>');
							}else {
								$(".seconds").html(second);
							}
						}
					}
				})(jQuery);

				//]]>
			</script>
		</div>




		<div class="nav-html">
			<h3><?php echo $this->__('All Catagories') ?></h3>
			<ul style="display: none;"></ul>
		</div>
		<div class="activity_product">
			<?php 
				$loaderimg = $this->getUrl().'skin/frontend/em0131/default/images/opc-ajax-loader.gif';
				$trollerUrl   = $this->getUrl('')."categorypage/automobiles/automobiles/";//控制器路径
			?>		
			<div class="sf-products"></div>
			<div class="sf-click-move"><?php echo $this->__('Смотреть ещё') ?></div>
			<script type="text/javascript">
			//<![CDATA[
			(function($){
				/*弹窗定位随窗口滚动显示不同*/
		        var activity = $(".activity").offset().top;
		        var activity_product = $(".nav-html").offset().top;
		        $(window).scroll(function () {
		            if ($(window).scrollTop() > activity-52 ) {
						$('.sf_coupon').css("position","fixed");
		            }else{
						$('.sf_coupon').css("position","absolute");
		            }

		            if ($(window).scrollTop() > activity_product) {
						$('.nav-html').addClass("scro");
		            }else{
						$('.nav-html').removeClass("scro");
		            }
		        });


				/*加载更多产品。。。*/
				var trollerUrl = "<?php echo $trollerUrl ?>";
				var Loadhtml = '<div class="sf-products-clic"><div class="text-center"><img src="<?php echo $loaderimg; ?>" alt="Click to load more..."/></div></div>';
				var Objct = $(".activity_product .sf-products");

				$(function () {
					Objct.append(Loadhtml);
					var Objlist = Objct.children().length;
					bottPost(trollerUrl,'load',Objlist);
				})

				$('.sf-click-move').click(function(){
					$('.sf-click-move').css("display","none");

					Objct.append(Loadhtml);
					var Objlist = Objct.children().length;
					bottPost(trollerUrl,'click',Objlist);
				});

				function bottPost(trollerUrl,code,size){
					var documen = Objct.children().last();
					var documen = Objct.children();
					$.post(trollerUrl ,{
						"code":code,
						"size":size
					},function(returns){
						var size = returns.size-1;
						if(returns.info == 'success'){
							$('.sf-click-move').css("display","block");
							documen.eq(size).html(returns.products);
						}else if(returns.info == 'cease'){
							documen.eq(size).html(returns.products);
							$('.sf-click-move').remove();

						}else if(returns.info == 'ends'){
							$('.sf-click-move').remove();
							documen.eq(size).remove();
						}
						var listProduct = documen.eq(size).children('.sf-products-list');
						
						for (var i = 0; i < listProduct.length; i++) {
							var hybrid = listProduct.eq(i).children('.button-hide-text');
							var hybridTxt = hybrid.text();
							hybrid.before('<a name="infoClick-'+size+'-'+i+'"></a>');
							var listF = (size*3)+(i+1);
							$('.nav-html ul').append('<li><a href="#infoClick-'+size+'-'+i+'">'+hybridTxt+'</a></li>')
						}

						$('#nav-html').owlCarousel();
					},"json")
				}
				$('.nav-html').click(function(){
					$('.nav-html ul').toggle();
				})
			})(jQuery);
			//]]>
			</script>
		</div>





		<div class="activity_blog">
			
		</div>
	</div>
</div>







<!-- 分享 -->
<div class="sf-share">
	<ul>
		<li><a href="" style="background-position：0px -37px"></a></li>
	</ul>
</div>

<script type="text/javascript">
    /* lie 图片懒加载 */
    (function($){
        $(function() {
            $("img.lazy").lazyload({
                event : "sporty",
                effect: "fadeIn"
            });
        });

        $(window).bind("load", function() {
            var timeout = setTimeout(function() {
                $("img.lazy").trigger("sporty")
            }, 5000);
        });
    })(jQuery);
    /* lie 图片懒加载 */
</script>
